//
//  MainViewController.m
//  Community
//
//  Created by YaSha_Tom on 2018/12/25.
//  Copyright © 2018年 YaSha-Tom. All rights reserved.
//

#import "MainViewController.h"
#import "UIImage+LX.h"
#import "YSMineTopView.h"

@interface MainViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) YSMineTopView *mineTopView;
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong) NSArray *titleArray;
@end

@implementation MainViewController
- (YSMineTopView *)mineTopView {
    if (!_mineTopView) {
        _mineTopView = [[YSMineTopView alloc] init];
    }
    return _mineTopView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我的";
    self.view.backgroundColor = [UIColor whiteColor];
    self.titleArray = @[@"我的关注",@"我的收藏",@"系统设置",@"退出登录"];
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 200*kHeightScale+kTopHeight, kSCREEN_WIDTH, kSCREEN_HEIGHT-200*kHeightScale-kTopHeight) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    [self.view addSubview:self.mineTopView];
    [self setupNavBar];
    UIButton *button = [[UIButton alloc]initWithFrame:CGRects(0, 30, 59, 14)];
    //右边按钮
    [button addTarget:self action:@selector(generateOrders) forControlEvents:UIControlEventTouchUpInside];
    [button setTitle:@"登录" forState:UIControlStateNormal];
    button.titleLabel.font=[UIFont systemFontOfSize:17.0*BIZ];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.rightBarButtonItem = item1;
}
- (void)setupNavBar {
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    self.navigationController.navigationBar.translucent = NO;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage getImageWithColor:[UIColor qmui_colorWithHexString:@"E7494D"]] forBarMetrics:UIBarMetricsDefault];
    
    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.titleArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.01;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return nil;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.row == 3) {
         cell.accessoryType =  UITableViewCellAccessoryNone;
        cell.textLabel.textAlignment = NSTextAlignmentCenter;
        cell.textLabel.textColor = [UIColor qmui_colorWithHexString:@"E7494D"];
    }
    cell.textLabel.text = self.titleArray[indexPath.row];
    return cell;
}

@end
